package drazing;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JLabel;

/**
 * Dialogo "Acerca de..."
 * @author xcubo
 */
public class AboutDiag extends JDialog
{
    private int wid = 450, hei = 425;
    private int left, up;

    private JLabel version, header, text, feat, icon;
    private BufferedImage logo;

    public AboutDiag(Dimension dim)
    {
        left= (dim.width/2) - (wid/2);
        up  = (dim.height/2)- (hei/2);

        setTitle("RAZING2D");

        addWindowListener(new WindowAdapter()
                {
                    @Override public void windowClosing(WindowEvent e) {
                            dispose();
                        }
                });

        version = new JLabel("v1.01");
        header = new JLabel("CopyLeft - Abril 2010");
        text = new JLabel(  "<html>2Drazing es un videojuego de carreras de coches " +
                            "con visión superior desarrollado utilizando la API " +
                            "Java2D para la asignatura Sistemas Multimedia. " +
                            "Configura tu coche e intenta batir el record!" +
                            "<p align=center>Ingeniería Informática - Universitat de València</html>");
        feat = new JLabel(  "<html><p>Musica:" +
                            "<p align=center>duckett - 2#Nine" +
                            "<p align=center>donnie drost - Static Attraction" +
                            "<p align=center>Ruin Roads - Death March to Sun Fun City" +
                            "<p align=center>Zapac - Test Drive" +
                            "<p align=center>Morusque - Jar Hut" +
                            "<p align=center>teru - Plunktrack" +
                            "<p align=center>DoKashiteru - The Annual New England Xylophone Symposium" +
                            "<p>Iconos: " +
                            "<p align=center>       http://icons.mysitemyway.com " +
                            "<p align=center>       http://www.iconeasy.com" +
                            "<p>Autor:" +
                            "<p align=center>       Jorge Belenguer Beltrán</html>");
        try {logo = ImageIO.read(getClass().getResource("../resources/img/logo/LogoGood.png"));}
        catch (IOException e) {}
        ImageIcon ico = new ImageIcon(logo);
        icon = new JLabel(ico);

        setLayout(new GridBagLayout());
        GridBagConstraints constraints = new GridBagConstraints();

        constraints.gridx = 0; 
        constraints.gridy = 0; 
        constraints.gridwidth = 1;
        constraints.gridheight = 1;
        constraints.weightx = 1.0;
        constraints.fill = GridBagConstraints.HORIZONTAL;
        add(version, constraints);
 
        constraints.gridy = 1;
        add(header, constraints);

        constraints.gridy = 2;
        constraints.gridwidth = 3;
        
        //constraints.anchor = GridBagConstraints.NORTH;
        add(text, constraints);

        constraints.weightx = 0.0;
        constraints.weighty = 0.0;
        constraints.fill = GridBagConstraints.NONE;
        constraints.gridy = 3;
        constraints.gridwidth = 1;
        add(feat, constraints);

        constraints.gridx = 1;
        constraints.gridwidth = 1; 
        //constraints.gridheight = 1;
        //constraints.fill = GridBagConstraints.BOTH;
        constraints.anchor = GridBagConstraints.EAST;
        add(icon, constraints);

        setLocation(left, up);
        setSize(wid, hei);
        setAlwaysOnTop(true);
        setResizable(false);
        setModal(true);
        setVisible(true);
    }
}

class OKListener implements ActionListener
{
    AboutDiag diag;
    public OKListener(AboutDiag dia)
        {diag=dia;}

    @Override public void actionPerformed( ActionEvent evento )
    {
        diag.dispose();
        System.out.println("OK");
    }
}

